package cn.itsource.hrm.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author jinhui
 * @version V1.0.0
 * @date 2020/6/5
 */
@Configuration
public class RabbitmqConfig {
    private static final String EXCHANG_NAME="hrm-couseTypes-test2";
    public static final String QUEUE_NAME = "page-agent-test2";

    @Bean(EXCHANG_NAME)
    public Exchange EXCHANGE_TOPICS_INFORM() {
        //durable(true)持久化，消息队列重启后交换机仍然存在
        return ExchangeBuilder.directExchange(EXCHANG_NAME).durable(true).build();
    }

    /**
     * 测试队列
     * @return
     */
    @Bean(QUEUE_NAME)
    public Queue QUEUE_INFORM_SMS() {
        Queue queue = new Queue(QUEUE_NAME);
        return queue;
    }

    @Bean
    public Binding BINDING_QUEUE_INFORM_SMS(@Qualifier(QUEUE_NAME) Queue queue,
                                            @Qualifier(EXCHANG_NAME) Exchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("page.home").noargs();
    }



}
